package com.dididoctor.patient.Bean;

import org.litepal.crud.DataSupport;

import java.io.Serializable;
import java.util.List;

public class DiaeasesLitapal extends DataSupport implements Serializable{


//	"disId": "1",   //24种小病
//			"name": "小病名称"
	
	private String disId;
	private String name;

	public String getDisId() {
		return disId;
	}

	public void setDisId(String disId) {
		this.disId = disId;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}


	/**
	 * 医院列表
	 * @return
	 */
	public static List<DiaeasesLitapal> getHospitallitapalCity(String disId){
		List<DiaeasesLitapal> findAll = DataSupport.where("disId = ?",disId).find(DiaeasesLitapal.class);
		return findAll;
		
	}
	
	/**
	 * 医院列表模糊查询
	 * @return
	 */
	public static List<DiaeasesLitapal> getAllHospitallitapal(String name,String disId){
		 List<DiaeasesLitapal> find = DataSupport.where("name like ? and disId = ?", "%" + name + "%",disId).find(DiaeasesLitapal.class);
		return find;
		
	}

	/**
	 * 通过id遍历数据
	 * @param disId
	 * @return
	 */
	public static DiaeasesLitapal getidHospitallitapal(String disId){
			List<DiaeasesLitapal> all = DataSupport.where(" disId = ?" ,disId).find(DiaeasesLitapal.class);
		if (all.size()>0 && all !=null){
			return all.get(0);
		}
		    return null;
	}

	/**
	 * @param
	 * @return
	 */
	public static List<DiaeasesLitapal> getdisarases(){
		List<DiaeasesLitapal> all = DataSupport.findAll(DiaeasesLitapal.class);
		if (all.size()>0 && all !=null){
			return all;
		}
		return null;
	}

	/**
	 * 通过医院ID 获取对应内容
	 * @return
	 * @param hospitals
	 */
	public static String getHospitalIdName(String hospitals) {
		String name = "";
		if ("".equals(hospitals )&& hospitals !=null){
			String[] ids = (hospitals+",").split(",");
			for (int x = 0; x<ids.length;x++){
				DiaeasesLitapal hospitalLitapal = DiaeasesLitapal.getidHospitallitapal(ids[x]);
				if (hospitalLitapal != null){
					name += hospitalLitapal.getName()+",";
				}
			}
		}
		return name;
	}
}
